package com.softer.wxzj.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.LogOperation;
import com.softer.wxzj.mapper.LogOperationMapper;
import com.softer.wxzj.service.LogOperationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = { RuntimeException.class, Exception.class })
public class LogOperationServiceImpl implements LogOperationService {

    @Autowired
    private LogOperationMapper operationMapper;


    @Override
    public CommonResult insert(LogOperation logOperation) {
        return null;
    }

    @Override
    public CommonResult update(LogOperation logOperation) {
        return null;
    }

    @Override
    public CommonResult delete(String id) {
        int i = operationMapper.delete(id);
        return CommonResult.ResponseResult(i);
    }

    @Override
    public PageInfo<LogOperation> getList(Page page, LogOperation logOperation) {
        //只有紧跟在PageHelper.startPage方法后的第一个Mybatis的查询（Select）方法会被分页。
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        List<LogOperation> list = operationMapper.getList(logOperation);
        PageInfo<LogOperation> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public LogOperation getInfo(String id) {
        return null;
    }
    /**
     * 模糊查询
     */
    @Override
    public PageInfo<LogOperation> fuzzySearch(Page page,String fuzzy){
        //只有紧跟在PageHelper.startPage方法后的第一个Mybatis的查询（Select）方法会被分页。
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        List<LogOperation> list = operationMapper.fuzzySearch(fuzzy);
        PageInfo<LogOperation> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
